package com.changyue.activity.mainTab.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.changyue.activity.history.entity.TestDataEntity;
import com.changyue.blood.R;

import java.util.List;

public class TestDataAdapter extends BaseAdapter {
    private List<TestDataEntity> mDevices;
    private LayoutInflater mInflater;

    public TestDataAdapter(Context context, List<TestDataEntity> devices) {
        mInflater = LayoutInflater.from(context);
        mDevices = devices;
    }

    public int getCount() {
        return mDevices.size();
    }

    public Object getItem(int position) {
        return mDevices.get(position);
    }

    public long getItemId(int position) {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        ViewGroup vg;

        if (convertView != null) {
            vg = (ViewGroup) convertView;
        } else {
            vg = (ViewGroup) mInflater.inflate(R.layout.test_data_item, null);
        }

        TestDataEntity testDataEntity = mDevices.get(position);
        ((TextView) vg.findViewById(R.id.ch1)).setText(testDataEntity.ch1 + "na");
        ((TextView) vg.findViewById(R.id.ch2)).setText(testDataEntity.ch2 + "na");

        return vg;
    }
}
